<?php
/**
 * Created by PhpStorm.
 * User: 哇咔咔
 * Date: 17-9-4
 * Time: 上午11:11
 */


defined('BASEPATH') OR exit('No direct script access allowed');

class News extends MY_Controller {
    function index(){
        $data['company'] = parent::company();//公司基本信息
        $column = parent::column('资讯管理');//获取栏目id
        $data['url'] =parent::pic_url($data['company'] ['id']);
        $arr = array(
            'company_id'=>$data['company'] ['id'],
            'pic_type' =>  '02',
            'del_flag' =>  '0',
            'column_id' => $column['id']
        );
        $arr1 = parent::arr();
        $data['pic'] = $this->db->from('picture')->where($arr)->get()->row_array();
        //获取新闻类型
        $data['news_type'] = $this->db->from('news_type')->where($arr1)->get()->result_array();
        //获取新闻列表
        $data['news_info'] = $this->db->from('news_info')->where($arr1)->get()->result_array();
        $this->load->view('news/news_list',$data);
    }


    //新闻的详细信息
    function info(){
        $id = $this->uri->segment(4);
        $data['company'] = parent::company();//公司基本信息
        $data['url'] =parent::pic_url($data['company'] ['id']);
        $arr = parent::arr_id($id);
        //获取新闻详情
        $data['news_info'] = $this->db->from('news_info')->where($arr)->get()->row_array();
        $this->load->view('news/news_show',$data);
    }


        //当点击新闻类型时
        function type(){
            $id = $this->uri->segment(4);
            $data['company'] = parent::company();//公司基本信息
            $data['url'] =parent::pic_url($data['company'] ['id']);
            $arr1 = parent::arr();
            if($id!='both'){
                $arr = array('type_id'=>$id,'company_id'=>$data['company'] ['id'],'del_flag' =>  '0',);}
            else{
                $arr = parent::arr();
            }
            //获取新闻类型
            $data['news_type'] = $this->db->from('news_type')->where($arr1)->get()->result_array();
            //获取对应类型的新闻列表
            $data['news_info'] = $this->db->from('news_info')->where($arr)->get()->result_array();
            $this->load->view('news/news_list',$data);
        }

}